// 使用node17
const fs = require('fs');
const { createFFmpeg, fetchFile } = require('@ffmpeg/ffmpeg');
const ffmpeg = createFFmpeg({ log: true });
(async () => {
  let t1 = Date.now();
  await ffmpeg.load();
  ffmpeg.FS('writeFile', 'test.avi', await fetchFile('./test.avi'));
  await ffmpeg.run('-i', 'test.avi', 'test123.mp4');
  await fs.promises.writeFile('./test123.mp4', ffmpeg.FS('readFile', 'test123.mp4'));
  console.log(Date.now() - t1);
  process.exit(0);
})();